import Vue from 'vue'
import App from './App.vue'
import router from './router'
import './plugins/element.js'

// 导入字体图标
import './assets/fonts/iconfont.css'
// 导入全局样式表
import './assets/css/global.css'

import TreeTable from 'vue-table-with-tree-grid';
import VueQuillEditor from 'vue-quill-editor';
import NProgress from 'nprogress'
import 'nprogress/nprogress.css'

import axios from 'axios'
axios.defaults.baseURL = 'http://localhost:8081/api/v1/login'
axios.interceptors.request.use(config=>{
    console.log(config)
    NProgress.start()
    config.headers.Authorization = window.sessionStorage.getItem('token');
    return config
})
axios.interceptors.response.use(config=>{
    NProgress.done()
    return config
})

Vue.prototype.$http = axios

Vue.config.productionTip = false

Vue.component('TreeTable',TreeTable)
Vue.use(VueQuillEditor)


Vue.filter('dateFormat',function(originVal){
    const dt = new Date(originVal);
    const y = dt.getFullYear();
    const m = (dt.getMonth() + 1 + '').padStart(2,'0');
    const d = (dt.getDate() + '').padStart(2,'0');

    return `${y}-${m}-${d}`
})
new Vue({
  router,
  render: h => h(App)
}).$mount('#app')
